package com.homelock.domain;

import com.homelock.entity.HlCommunityAdv;
import com.pi.base.enumerate.record.RecordState;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * 物业公司广告Dto
 */
public class CommunityAdvDto implements Serializable {
    private Long id;
    /**
     * 物业ID
     */
    private Long communityId;
    /**
     * 缩略图url
     */
    private String thumbnailUrl;
    /**
     * 大图url
     */
    private String picUrl;
    /**
     * 广告链接
     */
    private String linkUrl;
    /**
     * 广告位排序
     */
    private Integer advSort;
    private String createDate;


    public Long getCommunityId() {
        return communityId;
    }

    public void setCommunityId(Long communityId) {
        this.communityId = communityId;
    }

    public String getThumbnailUrl() {
        return thumbnailUrl;
    }

    public void setThumbnailUrl(String thumbnailUrl) {
        this.thumbnailUrl = thumbnailUrl;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }

    public String getLinkUrl() {
        return linkUrl;
    }

    public void setLinkUrl(String linkUrl) {
        this.linkUrl = linkUrl;
    }

    public Integer getAdvSort() {
        return advSort;
    }

    public void setAdvSort(Integer advSort) {
        this.advSort = advSort;
    }

    public Long getId() {
        return id;
    }

    public String getCreateDate() {
        return createDate;
    }

    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public HlCommunityAdv convertToEntity(){
        HlCommunityAdv target = new HlCommunityAdv();
       // CGlibMapper.mapperObject(this,target);
        Date current = new Date();
        target.setCreateDate(current);
        target.setUpdateDate(current);
        target.setVersion(1L);
        target.setState(RecordState.STATE_NORMAL.getState());
        target.setLinkUrl(StringUtils.trimToEmpty(this.getLinkUrl()));
        target.setPicUrl(StringUtils.trimToEmpty(this.getPicUrl()));
        target.setThumbnailUrl(StringUtils.trimToEmpty(this.getThumbnailUrl()));
        target.setAdvSort(this.getAdvSort() == null ? 0 : this.getAdvSort().byteValue());
        target.setId(this.getId());
        target.setCommunityId(this.getCommunityId());
        return target;
    }
}
